<?php

#################################################################
#								HTML
#################################################################

/**
 * Title element register as 'element/title' 
 * 
 * $vars['title']			Page title (String)
 * $vars['pulsate']			Blink text effect (int)
 * $vars['class']			Element class (String)
 * $vars['id']				Element id (String) 
 * 
 */

if($_CONTEXT=='HTML'){
	
	$_CSS_STACK->push(blg_get_site_url().'element/title.css');
	$_JS_STACK->push(blg_get_site_url().'element/title.js');		
	
	//PREPARE DEFAULTS	
	if(!is_int($vars['pulsate']))
		$vars['pulsate']= 0;		
		
	$class= 'title_element';
	if(!empty($vars['class']))
		$vars['class']= $class.' '.$vars['class'];
	else
		$vars['class']= $class;

	if(empty($vars['id']))
		$vars['id']= 'title_'.random_string(12);		

echo <<<HTML
<span id="$vars[id]" class="$vars[class]">$vars[title]</span>
HTML;

	if($vars['pulsate']>0){
		$code="$('#".$vars['id']."').effect('pulsate', { times:".$vars['pulsate']." }, 900);";		
		$_JS_CODE->append($code, ON_DOC_READY);				
	}
	else{
		$code="
			blg_element_title_effect('".$vars['id']."');
			blg_element_title_animate('".$vars['id']."');				
		";
		
		$_JS_CODE->append($code, ON_DOC_READY);				
	}

}
#################################################################
#								JS
#################################################################
elseif($_CONTEXT=='JS'){ ?>

function blg_element_title_color1(id){
	$('#'+id).animate({color: '#0066CC'}, 1000 );
}

function blg_element_title_color2(id){
	$('#'+id).animate({color: '#0281ff'}, 1000 );
}

function blg_element_title_effect(id){
	blg_element_title_color1(id);
	setTimeout('blg_element_title_color2(\''+id+'\')', 1000);
}

function blg_element_title_animate(id){
	setInterval('blg_element_title_effect(\''+id+'\')', 5000);
}

<?php }
#################################################################
#								CSS
#################################################################
elseif($_CONTEXT=='CSS'){ ?>

span.title_element{
	display: inline;
	font-size: 22px;
	line-height: 24px;
	color: #0066CC;	
	font-weight: bold;
	font-family: arial,verdana,tahoma,sans-serif;
	padding: 2px 0 5px 0;
}

<?php }
